package com.company.Lab1;

import java.util.Scanner;

public class Realist {
    public static void main(String[] args) {
        int[][] realistArr;
        int[] rmax = new int[10];
        int[] rmin = new int[10];
        float alpha, maxR = 0;
        float[] result = new float[10];

        Scanner scanner = new Scanner(System.in);
        int r, c;

        System.out.println("Introducerti numarul de randuri : ");
        r = scanner.nextInt();
        System.out.println("Introduceti numarul de coloane : ");
        c = scanner.nextInt();

        realistArr = new int[r][c];

        System.out.println("Introduceti datele matrcii :");

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print("[" + i + "][" + j + "] : ");
                realistArr[i][j] = scanner.nextInt();
            }
        }

//        calcule
//        aflam maximumul pe rand
        for (int i = 0; i < r; i++) {
            int max = realistArr[i][1];
            for (int j = 0; j < c; j++) {
                if (max <= realistArr[i][j]) {
                    max = realistArr[i][j];
                }
            }
            rmax[i] = max;
        }
        System.out.println("Valorile maxime pe rand sunt : ");
        for (int i = 0; i < r; i++) {
            System.out.println(rmax[i] + "\t");
        }
//        afmam minimumul pe rand
        for (int i = 0; i < r; i++) {
            int min = realistArr[i][1];
            for (int j = 0; j < c; j++) {
                if (min >= realistArr[i][j]) {
                    min = realistArr[i][j];
                }
            }
            rmin[i] = min;
        }
        System.out.println("Valorile minime pe rand sunt : ");
        for (int i = 0; i < r; i++) {
            System.out.println(rmin[i] + "\t");
        }
//        logica pentru huriz
        System.out.println("Introduceti coeficientul alfa : ");
        alpha = scanner.nextFloat();
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                result[i] = (alpha * rmax[i]) + ((1 - alpha) * rmin[i]);
            }
        }
        for (int i = 0; i < r; i++) {
        maxR = Math.max(maxR,result[i]);
        }
        System.out.println("Rezultatul criteriului realist este : " + maxR);
    }
}
